﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Attributes
{
    [AttributeUsage(AttributeTargets.Method)]
    class VersionAttribute : Attribute
    {
        public string Version { get; set; }
        public string Comment { get; set; }

        public VersionAttribute(string version, string comment = null)
        {
            Version = version;
            Comment = comment;
        }

        public override string ToString()
        {
            if (Comment != null)
            {
                return string.Format("{0} ({1})", Version, Comment);
            }
            else
            {
                return Version;
            }
        }
    }

    class Program
    {
        [Version("1.0", "initial version")]
        public static void Asd()
        {
            MethodInfo methodInfo = typeof(Program).GetMethod("Asd");

            var attributes = Attribute.GetCustomAttributes(methodInfo);

            foreach (VersionAttribute item in attributes)
            {
                Console.WriteLine(item);
            }

        }


        static void Main(string[] args)
        {
            Asd();
        }
    }
}
